package top.maohh.study.redis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.maohh.study.redis.entity.Person;

/**
 * @author maohh
 */
@RestController()
@RequestMapping("room")
public class PushController {
    @Autowired
    RedisTemplate redisTemplate;

    @GetMapping("push")
    public String push() {
        Person person1 = new Person();
        person1.setId(1);
        person1.setName("一号");
        Person person2 = new Person();
        person2.setId(2);
        person2.setName("二号");
        redisTemplate.convertAndSend("shop001", person1);
        redisTemplate.convertAndSend("shop001", person2);
        return "PUSH SUCCESS!";
    }
}
